package muilt;

import java.util.List;

import org.apache.commons.collections.CollectionUtils;

import com.google.common.base.CharMatcher;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;

import cn.hutool.core.collection.CollectionUtil;

public class StringInsert {
	public static void main(String[] args) {
		String url = "http://localhost:8082/cf_fpb/fupin/?iw-apikey=123&iw-cmd=pinkunhuxinxiliebiao&ND=2019&SZXIAN=150402000000&YM=1";
		//String result = CharMatcher.forPredicate(Character::isLetterOrDigit).retainFrom(url);
		if(url.indexOf("&iw-cmd=") >=0 || url.indexOf("?iw-cmd=") >=0){
			List<String> first = Lists.newArrayList(Splitter.on("?").omitEmptyStrings().trimResults().split(url));
			List<String> two = Lists.newArrayList(Splitter.on("&").omitEmptyStrings().trimResults().split(first.get(1)));
			String iw = "";
			for(String l : two){
				if(l.indexOf("iw-cmd=") >=0 ){
					iw = l;
					two.remove(l);
					break;
				}
			}
			String joinStr = Joiner.on("&").skipNulls().join(two);
			String path = first.get(0)+ iw.split("=")[1] + "?" + joinStr;
			System.out.println(path);
		} 
	}
}
